package net.lzzy.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @GetMapping("/login")
    public String login(){

        return "login";
    }

    @PostMapping("/login")
    public String loginIn(@RequestParam("username") String username,@RequestParam("password") String password, HttpSession httpSession){
        if(username.equals("don") && password.equals("123")){
            httpSession.setAttribute("username","don");
            return "redirect:index";
        }
        else
            return "login";
    }
}
